package cn.ffcs.uec.staff.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cn.ffcs.uec.staff.dao.UecHightTeamDao;
import cn.ffcs.uec.staff.model.UecHightTeam;
import cn.ffcs.uom.common.constants.BaseUnitConstants;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("uecHightTeamDao")
@Transactional
public class UecHightTeamDaoImpl extends BaseDaoImpl implements UecHightTeamDao {

	@Override
	public PageInfo queryPageInfoByUecHightTeam(UecHightTeam uecHightTeam, int current,
			int pageSize) {
		if (null != uecHightTeam) {
			StringBuilder sb = new StringBuilder(
					" SELECT * FROM UEC_HIGHT_TEAM T WHERE 1 = 1 ");
			List<Object> params = new ArrayList<Object>();
			sb.append(" AND T.STATUS_CD = ? ");
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);

			//判断这个对象是外包人员的数据还是合同制的数据
			if (BaseUnitConstants.NM_OUT_STAFF_TYPE.equals(uecHightTeam.getNmStaffType())) {
				sb.append(" AND T.NM_STAFF_TYPE = ? ");
				params.add(BaseUnitConstants.NM_OUT_STAFF_TYPE);
			}
			
			if (!StrUtil.isNullOrEmpty(uecHightTeam.getPkPsndoc())) {//判断数据是否是集团的
				sb.append(" AND T.PK_PSNDOC = ? ");
				params.add(uecHightTeam.getPkPsndoc());
			} else if (!StrUtil.isNullOrEmpty(uecHightTeam.getStaffId())) {
				sb.append(" AND T.STAFF_ID = ? ");
				params.add(uecHightTeam.getStaffId());
			}
			return this.jdbcFindPageInfo(sb.toString(), params, current,
					pageSize, UecHightTeam.class);
		}
		return null;
	}
}
